var typeid;

function initPage(id, name, code) {
	typeid = id;
	// tabs for the center
	var tabs = new Ext.TabPanel({
				id : 'tabs',
				region : 'center',
				closable : true,
				resizeTabs : true,
				minTabWidth : 135,
				tabWidth : 135,
				deferredRender : false,
				enableTabScroll : true,
				margins : '3 3 3 0',
				items : []
			});

	var tree = new Ext.tree.TreePanel({
				region : 'west',
				id : 'tree',
				title : '<font class="oaFont">资产分类</font>',
				split : false,
				width : 200,
				collapsible : false,
				layoutConfig : {
					animate : true
				},
				margins : '3 3 3 3',
				cmargins : '3 3 3 3',
				// onlyLeafCheckable : true,
				autoScroll : true,
				animate : true,
				rootVisible : true,
				loader : new Ext.tree.TreeLoader({
							dataUrl : context
									+ '/system/ddindexshow.do?method=tree',
							baseParams : {

				}
						}),
				root : new Ext.tree.AsyncTreeNode({
							allowChildren : true,
							expanded : true,
							text : name, // 节点名称
							code : code,
							draggable : false, // 是否支持拖动
							iconCls : 'root',
							cls : 'rootFont',
							id : id
						}),
				listeners : {
					'click' : function(node) {
						/*
						 * if (node.isExpanded()) { node.collapse(); } else {
						 * node.expand(); }
						 */
						initTQExtTabList('_' + node.id, tabs, 'gdzctempdjlist',
								function(gridId) {
									Ext.getCmp(gridId)
											.setTitle('<font class="oaFont">'
													+ node.text + '</font>');
								}, null, '&typeId=' + node.id + '&typeCode='
										+ node.attributes.code);
					},
					'checkchange' : function(node, checked) {
						if (checked) {
							if (selectedLanmuNode) {
								selectedLanmuNode.attributes.checked = false;
								selectedLanmuNode.ui.checkbox.checked = false;
							}

							selectedLanmuNode = node;
						}
					}
				}
			});

	tree.getRootNode().expand(true);

	var win = new Ext.Window({
				id : 'win_' + id,
				title : '<font class="oaFont">' + name + '_登记向导</font>',
				closable : false,
				resizable : false,
				// maximizable : true,
				width : 800,
				height : 500,
				border : false,
				plain : true,
				layout : 'border',
				modal : true,
				listeners : {
					'show' : function() {
                        tree.getRootNode().fireEvent('click', tree.getRootNode());
					}
				},
				items : [tree, tabs]
			});

	win.show(this);
}

/**
 * render cell
 * 
 * @param {}
 *            value
 * @param {}
 *            cellmeta
 * @param {}
 *            record
 * @param {}
 *            rowIndex
 * @param {}
 *            columnIndex
 * @param {}
 *            store
 * @return {}
 */
function renderTQExtTabListHeader(value, cellmeta, record, rowIndex,
		columnIndex, store) {
	var cm = getGridCm('gdzctempdjlist' + nowTabId);

	var fieldName = cm.getDataIndex(columnIndex);

	if (fieldName == 'TNAME') {
		var resultString = String.format('<a title="点击进行资产登记" href="' + context
						+ '/app/gdzc/gzneu.jsp?id={0}">{1}</a>',
				record.data['ID'], value);

		return resultString;
	} else if (fieldName == 'TDATE') {
		return formatDate(value);
	}
	return value;
}